import Qt 4.7

Rectangle {
    id: container

    width: 640; height: 360
    color: "transparent"

    signal ok
    signal cancel
    signal callMessageBox(string mesgBox, string nextView)

    Text {
        id: label

        anchors { top: parent.top; topMargin: 39; left: parent.left; right: parent.right }
        horizontalAlignment: Text.AlignHCenter

        text: "Nova Conta"; color: "white"
        font { pointSize: 9; family: "Series 60 Sans" }
    }

    Text {
        id: loginLabel

        x: 166; y: 109
        text: "Login"; color: "#00adef"
        font { pointSize: 5; family: "Series 60 Sans" }
    }

    LineEdit {
        id: loginLineEdit

        x: 233; y: 94; width: 252; height: 52
        color: "#d1d3d4"
        fontPointSize: 9
    }

    Text {
        id: passwordLabel

        x: 166; y: 168
        text: "Senha"; color: "#00adef"
        font { pointSize: 5; family: "Series 60 Sans" }
    }

    LineEdit {
        id: passwordLineEdit

        x: 233; y: 153; width: 252; height: 52
        color: "#d1d3d4"
        fontPointSize: 9
        echoMode: TextInput.Password
    }

    Text {
        id: repeatLabel

        x: 166; y: 220; width: 67
        wrapMode: Text.WordWrap
        text: "Repetir Senha"; color: "#00adef"
        font { pointSize: 5; family: "Series 60 Sans" }
    }

    LineEdit {
        id: repeatLineEdit

        x: 233; y: 212; width: 252; height: 52
        color: "#d1d3d4"
        fontPointSize: 9
        echoMode: TextInput.Password
    }

    Button {
        id: cancelButton

        x: 233; y: 272
        width: 92; height: 51;
        defaultColor: "transparent"; pressedColor: "transparent"
        text: "Cancelar"; textColor: "#00adef"

        onClicked: {
            loginLineEdit.text = ''
            passwordLineEdit.text = ''
            repeatLineEdit.text = ''
            container.cancel()
        }
    }

    Button {
        id: okButton

        x: 378; y: 272
        width: 92; height: 51
        text: "OK"; textColor: "white"

        onClicked: {
            // Insert database code here

            if (passwordLineEdit.text == repeatLineEdit.text) {
                if (daoManager.createUser(loginLineEdit.text, passwordLineEdit.text))
                    container.ok();
                else container.callMessageBox('Erro ao inserir usuario no banco', 'loginBox');
            }
        }
    }
}

